﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using WPFExcelReport.Controls;
using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// TBList="ICC_STDMACHINE;ICC_QUERYTB;HRSTAMM;MKRF;AMSTAMM;ABPOS;ICC_ABAX;AMSTAMM;ICC_MKRF;ICC_PVKPOS;ICC_JWYARN;ABFOLGE;";//ITXAV95
    /// </summary>
    public partial class ITXAV95 : DocumentBase
    {
        #region-------------Properties-----------------------

        ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        public INTEXDBC INTEXDBC
        {
            get
            {
                return app.INTEXDBC;
            }
        }
        public INTEXBL INTEXBL
        {
            get
            {
                return app.INTEXBL;
            }
        } 
 
        MainViewModel vm;
        public SETINTEXDB SetEnv
        {
            get
            {
                return vm.SetEnv;
            }
        }
  
        public SETINTEXDB SetData
        {
            get
            {
                return vm.SetData;
            }
        }
        public SETINTEXDB SetProd
        {
            get
            {
                return vm.SetProd;
            }
        }
        #region=====vwAMSTAMM=======
        CollectionViewSource vwAMSTAMM
        {
            get
            {
                return (CollectionViewSource)this.TryFindResource("vwAMSTAMM");
            }
        }
        DataRow dwAMSTAMM
        {
            get
            {
                if (vwAMSTAMM.View == null)
                    return null;
                if ((DataRowView)vwAMSTAMM.View.CurrentItem == null)
                    return null;
                return ((DataRowView)vwAMSTAMM.View.CurrentItem).Row;
            }
        }
        #endregion
        #region=====vwBMKRF=======
        CollectionViewSource vwBMKRF
        {
            get
            {
                return (CollectionViewSource)this.TryFindResource("vwBMKRF");
            }
        }
        DataRow dwBMKRF
        {
            get
            {
                if (vwBMKRF.View == null)
                    return null;
                if ((DataRowView)vwBMKRF.View.CurrentItem == null)
                    return null;
                return ((DataRowView)vwBMKRF.View.CurrentItem).Row;
            }
        }
        #endregion
        #region=====vwBMKRF=======
        CollectionViewSource vwMRILI
        {
            get
            {
                return (CollectionViewSource)this.TryFindResource("vwMRILI");
            }
        }
        DataRow dwMRILI
        {
            get
            {
                if (vwMRILI.View == null)
                    return null;
                if ((DataRowView)vwMRILI.View.CurrentItem == null)
                    return null;
                return ((DataRowView)vwMRILI.View.CurrentItem).Row;
            }
        }
        #endregion 
        #endregion
        public ITXAV95()
        {
            InitializeComponent();
            this.Name = "订单网络";
            vm = new MainViewModel();
            DataContext = vm;
            txtUserID.Text = app.User;
            txtPassword.Password = app.Pwd; 
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataSet SResult;
            try
            {
                if (IsLoaded) return;
                IsLoaded = true; 

               
                
              }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return;

        }
        private void btnLogIn_Click(object sender, RoutedEventArgs e)
        {
            string Mandant = txtMANDANT.Text.ToUpper();
            string userID = Helpers.Helper.Left(txtUserID.Text.ToUpper() + "        ", 8);
            System.Security.SecureString SPassword = txtPassword.SecurePassword;
            IntPtr p = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(SPassword);
            string Password = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(p);
            DataRow dwHR = app.UserValid(userID, Password);
            if (dwHR == null)
            {
                MessageBox.Show("请检查登陆信息");
                return;
            }
            txtLogIn.Background = new SolidColorBrush(Colors.Green);
            expLog.IsExpanded = false;
            expLog.Visibility = Visibility.Collapsed;
        }
        private void btnLoadVKPList_Click(object sender, RoutedEventArgs e)
        {
            vm.LoadVKPList();
        }
        private void btnGotoDetail_Click(object sender, RoutedEventArgs e)
        {
            //tabDetail.Focus();
            vwVKP.ShowDetail();
        }

        private void btnDZoomIn_Click(object sender, RoutedEventArgs e)
        {
            vwVKPLIST.Visibility = Visibility.Hidden;
            vwVKP.SetValue(Grid.RowProperty, 1);
            vwVKP.SetValue(Grid.RowSpanProperty, 2);
        }

        private void btnDZoomOut_Click(object sender, RoutedEventArgs e)
        {
            vwVKPLIST.Visibility = Visibility.Visible;
            vwVKP.SetValue(Grid.RowProperty, 2);
            vwVKP.SetValue(Grid.RowSpanProperty, 1);
        }       

    }
}
